import java.util.*;
public class Main{
    public static boolean solutionLength(String[]arr){
        //判断是否按长度排序
        for(int i=0;i<arr.length-1;i++){
            if(arr[i].length()>arr[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static boolean solutionDict(String[]arr){
        //判断是否按字典序排序
        for(int i=0;i<arr.length-1;i++){
            if(arr[i].compareTo(arr[i+1])>0){
                return false;
            }
        }
        return true;

    }


    public static void main(String[]args){

        Scanner sc=new Scanner(System.in);

        int n=sc.nextInt();
        String[]arr=new String[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.next();
        }

        boolean isLengths=solutionLength(arr);
        boolean isDict=solutionDict(arr);
        //按两种情况结果综合输出答案
        if(isDict&&isLengths){
            System.out.println("both");
        }else if(isDict&&!isLengths){
            System.out.println("lexicographically");
        }else if(isLengths&&!isDict){
            System.out.println("lengths");
        }else{
            System.out.println("none");
        }
    }
}